﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EntityObjects;
using BAL.Controller;

namespace PresentationLayer.View.Clerk
{
    public partial class ViewRetrievalForm : System.Web.UI.Page
    {
        ConsolidateRetrivalControl control;
        int catid;
        protected void Page_Load(object sender, EventArgs e)
        {
           List<Category> categoryList = new List<Category>();            
           control = new ConsolidateRetrivalControl();
           if (!IsPostBack)
           {
               categoryList = control.getAllCategory();
               ddCategory.DataSource = categoryList;
               ddCategory.DataTextField = "categoryName";
               ddCategory.DataValueField = "categoryId";
               ddCategory.DataBind();

               gvRetrievalList.DataSource = null;
               gvRetrievalList.DataBind();
           }
           else
           {
               catid = Convert.ToInt32(ddCategory.SelectedItem.Value);
               List<Retrival> retrivalList = control.getRetrievalList(catid);
               if (retrivalList != null)
               {
                   gvRetrievalList.DataSource = retrivalList;
                   gvRetrievalList.DataBind();
                   Label5.Text = retrivalList.Count.ToString();
               }
               else
               {
                   Label5.Text = "Null Data";
               }
               GridView1.DataSource = retrivalList;
               GridView1.DataBind();
               
           }
        }
   }
}